#include "hash.h"
#include "boost/crc.hpp"


using namespace fortress;

hash::hash()
{
	init();
}

hash::~hash()
{

}

hash & hash::getInstance()
{
	static hash instance;
	return instance;
}

int hash::getHash(const std::string & str)
{
	boost::crc_32_type crc;
	crc.process_bytes(str.c_str(), str.length());
	return crc();
}
void hash::init()
{
	move_n=getHash(std::string("MOVE_N"));
	move_ne=getHash(std::string("MOVE_NE"));
	move_e=getHash(std::string("MOVE_E"));
	move_se=getHash(std::string("MOVE_SE"));
	move_s=getHash(std::string("MOVE_S"));
	move_sw=getHash(std::string("MOVE_SW"));
	move_w=getHash(std::string("MOVE_W"));
	move_nw=getHash(std::string("MOVE_NW"));
	open=getHash(std::string("OPEN"));
	close=getHash(std::string("CLOSE"));
	quit=getHash(std::string("QUIT"));
	pickup=getHash(std::string("PICKUP"));
	drop=getHash(std::string("DROP"));
	drop_list=getHash(std::string("DROP_LIST"));
	inventory=getHash(std::string("INVENTORY"));
	upstairs=getHash(std::string("UPSTAIRS"));
	downstairs=getHash(std::string("DOWNSTAIRS"));
	save=getHash(std::string("SAVE"));
}